#pragma once

#include "iterator.h"

namespace sfc::iter {

template <class A, class B>
struct Zip {
  using Item = tuple::Tuple<typename A::Item, typename B::Item>;

  A _a;
  B _b;

 public:
  auto next() -> option::Option<Item> {
    auto a = _a.next();
    if (!a) return {};

    auto b = _b.next();
    if (!b) return {};

    return Item{a.get_unchecked_mut(), b.get_unchecked_mut()};
  }

  auto operator->() -> Iter<Zip>* {
    return static_cast<Iter<Zip>*>(this);
  }
};

template <class A, class B>
Zip(A, B) -> Zip<A, B>;

}  // namespace sfc::iter
